<?php
/**
 * @file
 * @package mileage
 * @version $Id$
**/

if (!defined('XOOPS_ROOT_PATH')) {
	exit;
}

/**
 * Mileage_ImageObject
**/
class Mileage_RecObject extends XoopsSimpleObject
{
	//public $mileObject = NULL;
	public $mileName = NULL;

	/**
	 * __construct
	 * 
	 * @param   void
	 * 
	 * @return  void
	**/
	public function __construct()
	{
		$this->initVar('rec_id',       XOBJ_DTYPE_INT, '', FALSE);
		$this->initVar('point',        XOBJ_DTYPE_INT, '', FALSE);
		$this->initVar('mile_id',      XOBJ_DTYPE_INT, '', FALSE);
		$this->initVar('uid',          XOBJ_DTYPE_INT, '', FALSE);
		$this->initVar('reg_unixtime', XOBJ_DTYPE_INT, '', FALSE);
	}

	public function getMileObject($dirname)
	{
		$asset = NULL;
		XCube_DelegateUtils::call('Module.mileage.Global.Event.GetAssetManager', new XCube_Ref($asset), $dirname);
		$handler =& $asset->getObject('handler', 'mile');
		$mile =& $handler->getObjects(new Criteria('mile_id', $this->get('mile_id')));
		return $mile[0];
	}
}

/**
 * Mileage_ImageHandler
**/
class Mileage_RecHandler extends XoopsObjectGenericHandler
{
	/**
	 * @brief   string
	**/
	public $mTable = NULL;//'{dirname}_image';

	/**
	 * @brief   string
	**/
	public $mPrimary = 'rec_id';

	/**
	 * @brief   string
	**/
	public $mClass = 'Mileage_RecObject';

	/**
	 * __construct
	 * 
	 * @param   XoopsDatabase  &$db
	 * @param   string  $dirname
	 * 
	 * @return  void
	**/
	public function __construct(&$db, $dirname)
	{
		$this->mTable = $dirname . '_rec';//str_replace('{dirname}',$dirname,$this->mTable);
		parent::XoopsObjectGenericHandler($db);
	}
}

